function dt = TSdatenum(TSdt)
% dt = TSdatenum(TSdt) Convert a TS date into a standard date number 
%   TSdt (YYYYMMDD or YYYYMM).

if TSdt > 999999  %YYYYMMDD
   dt = datenum(floor(TSdt/10000), mod(floor(TSdt/100),100), mod(TSdt,100));
else   %YYYYMM
   dt = datenum(floor(TSdt/100), mod(TSdt,100), 1);
end

return
